<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <title>我的</title>
    <link rel="stylesheet" href="../../css/api.css">
    <link rel="stylesheet" href="../../css/vant.css">
    <link rel="stylesheet" href="../../css/main.css">
    <style>
    </style>
</head>

<body>
    <div class="app" v-cloak>
        <div class="common-header">
            <div class="iconfont goback" @click="back">&#xe66f;</div>
            <div class="title">我的动态</div>
        </div>
        <van-tabs class="my_tab_head" v-model="active" color="#3F8CEC" title-inactive-color="#666666"
            title-active-color="#3F8CEC" @click="setFrameGroupIndex">
            <van-tab :title="leftCount"></van-tab>
            <van-tab :title="rightCount"></van-tab>
        </van-tabs>
    </div>
    <script src="../../script/api.js"></script>
    <script src="../../script/flexible.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/vue.min.js"></script>
    <script src="../../script/iconfont.js"></script>
    <script src="../../script/vant.min.js"></script>
    <script src="../../script/common.js"></script>
    <script src="../../script/businessCommon.js"></script>
    <script src="../../script/restful.js"></script>
    <script>
        apiready = function () {
            vm = new Vue({
                el: '.app',
                data: {
                    queryInfo: {
                        pageSize: 10,
                        pageNum: 1,
                        screenType: null,
                    },
                    active: 0,
                    frames: [{
                        name: 'circle_list_frm',
                        url: '../circle_new/circle_list_frm.html',
                        pageParam: {
                            screenType: 3,
                        }
                    }, {
                        name: 'circle_list_frm',
                        url: '../circle_new/circle_list_frm.html',
                        pageParam: {
                            screenType: 2,
                        }
                    },],
                    headerH: 0,
                    leftCount: '作品',
                    rightCount: '赞过',

                },
                mounted() {
                    var headTop = $api.fixStatusBar($api.dom('.common-header'));

                    var header = $api.dom('.my_tab_head');
                    var headBottom = $api.offset(header).h;
                    this.headerH = headTop + headBottom

                    this.openFrameGroup();

                    this.getCount(3)
                    // this.getCount(2)
                },
                methods: {
                    getCount(type) {
                        var vm = this;
                        vm.queryInfo.screenType = type
                        if (vm.queryInfo.screenType == 3) {
                            //我的动态
                            circle("listAllMimeMoments")(vm.queryInfo, function (ret) {
                                vm.leftCount = "作品（" + ret.data.total + "）";
                            })
                        } else if (vm.queryInfo.screenType == 2) {
                            //点赞
                            circle("listAllLikeMoments")(vm.queryInfo, function (ret) {
                                vm.rightCount = "赞过（" + ret.data.total + "）";
                            })
                        }
                    },
                    back() {
                        api.closeWin();
                    },
                    openFrameGroup() {
                        var vm = this;
                        api.openFrameGroup({
                            name: 'mine_dynamic',
                            rect: {
                                marginTop: vm.headerH,
                            },
                            scrollEnabled: true,
                            frames: vm.frames,
                            preload: 1,
                            reload:true

                        }, function (ret, err) {
                            vm.active = ret.index;
                            // api.sendEvent({
                            //     name: 'eventTab',
                            //     extra: { key: ' value' }
                            // });
                        });
                    },

                    setFrameGroupIndex() {
                        api.setFrameGroupIndex({
                            name: 'mine_dynamic',
                            scroll: true,
                            index: this.active,
                            reload: true
                        });
                    },
                },
            })

   

            api.addEventListener({
                name: 'likeCount'
            }, function (ret) {
               vm.rightCount = ret.value.countStr
            })
            
            //删除后刷新数量
            api.addEventListener({
                name: 'refreshAllTopic'
            }, function (ret, err) {
                vm.getCount(3)
            });
        }
    </script>
</body>

</html>